﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:odc="clr-namespace:Odyssey.Controls"
        xmlns:fx="clr-namespace:Odyssey.Effects" xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Odyssey;Component/Themes/Ribbon/InternalRibbonButton.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <ControlTemplate TargetType="{x:Type odc:RibbonComboBox}" x:Key="RibbonComboBoxTemplate">
        <Grid Focusable="False">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid Focusable="False" Width="{TemplateBinding ContentWidth}" Grid.Column="2"
                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" x:Name="border"
                        Background="{TemplateBinding Background}" Focusable="False" Opacity="0.65" />
                <DockPanel HorizontalAlignment="Stretch" Focusable="False" Grid.Column="2">
                    <ToggleButton x:Name="button" Margin="0" DockPanel.Dock="Right" Width="16" Template="{StaticResource InternalToggleButton}"
                            IsChecked="{Binding IsDropDownOpen,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}" ClickMode="Press"
                            Focusable="False" HorizontalContentAlignment="Center">
                        <Image Margin="2,0,2,0" Stretch="None" VerticalAlignment="Center" HorizontalAlignment="Center" Focusable="False"
                                ClipToBounds="True" Source="{DynamicResource {ComponentResourceKey odc:Skins, DownArrowImage}}" />
                    </ToggleButton>
                    <Grid Focusable="False" x:Name="grid" DockPanel.Dock="Right" Margin="4,0,0,0" VerticalAlignment="Stretch">
                        <TextBox x:Name="PART_EditableTextBox" Focusable="True" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" BorderThickness="0" />
                        <ContentPresenter x:Name="content" Visibility="Collapsed" Focusable="False"
                                Content="{TemplateBinding ComboBox.SelectionBoxItem}"
                                ContentTemplate="{TemplateBinding ComboBox.SelectionBoxItemTemplate}"
                                ContentStringFormat="{TemplateBinding ComboBox.SelectionBoxItemStringFormat}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
                                SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                    </Grid>
                </DockPanel>
                <Popup IsOpen="{Binding IsDropDownOpen,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}" StaysOpen="False"
                        MinWidth="{Binding ActualWidth, ElementName=border}" Placement="Bottom"
                        PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" AllowsTransparency="True"
                        Name="PART_Popup" Focusable="False">
                    <mwt:SystemDropShadowChrome Color="#71000000" Name="Shdw2" Margin="0,0,5,5"
                            MinWidth="{Binding FrameworkElement.ActualWidth, ElementName=button,TargetNullValue=120}"
                            MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}">
                        <Border BorderThickness="1,1,1,1" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"
                                Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Name="DropDownBorder">
                            <StackPanel>
                                <ContentControl Content="{TemplateBinding DropDownHeader}" ContentTemplate="{TemplateBinding DropDownHeaderTemplate}" />
                                <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" CanContentScroll="True">
                                    <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                            KeyboardNavigation.DirectionalNavigation="Contained" Margin="1" />
                                </ScrollViewer>
                                <ContentControl Content="{TemplateBinding DropDownFooter}" ContentTemplate="{TemplateBinding DropDownFooterTemplate}" />
                            </StackPanel>
                        </Border>
                    </mwt:SystemDropShadowChrome>
                </Popup>
            </Grid>
            <Image Width="16" Height="16" Grid.Column="0" Source="{TemplateBinding Image}" VerticalAlignment="Center" Margin="4,2,0,2" x:Name="image"
                    RenderOptions.EdgeMode="Aliased"
                    RenderOptions.BitmapScalingMode="{Binding Path=(odc:ImageRenderOptions.SmallImageScalingMode), RelativeSource={RelativeSource TemplatedParent}}"
                    ClipToBounds="True" Focusable="False" />
            <TextBlock x:Name="text" Text="{TemplateBinding Title}" Grid.Column="1" VerticalAlignment="Center" Margin="2,0,2,0" Focusable="False"
                    Width="{TemplateBinding LabelWidth}" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEditable" Value="False">
                <Setter Property="Visibility" Value="Hidden" TargetName="PART_EditableTextBox" />
                <Setter Property="Visibility" Value="Visible" TargetName="content" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsEnabled" Value="False" />
                    <Condition Property="odc:RibbonChrome.IsGrayScaleEnabled" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Opacity" Value="{DynamicResource {ComponentResourceKey odc:Skins, DisabledImageOpacity}}" TargetName="image" />
                <Setter Property="RenderOptions.EdgeMode" Value="Unspecified" TargetName="image" />
                <Setter Property="RenderOptions.BitmapScalingMode" Value="Fant" TargetName="image" />
                <Setter Property="Effect" TargetName="image">
                    <Setter.Value>
                        <fx:GrayscaleEffect />
                    </Setter.Value>
                </Setter>
            </MultiTrigger>

            <Trigger Property="odc:RibbonBar.Size" Value="Small">
                <Setter Property="Visibility" Value="Collapsed" TargetName="text" />
            </Trigger>
            <Trigger Property="odc:RibbonBar.Size" Value="Minimized">
                <Setter Property="Visibility" Value="Collapsed" />
            </Trigger>

            <Trigger Property="IsMouseOver" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="Opacity" Duration="0:0:0.15" To="1" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="Opacity" Duration="0:0:0.15" From="1" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>
            <Trigger Property="IsFocused" Value="True">
                <Setter Property="Opacity" Value="1.0" TargetName="border" />
                <!--<Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey odc:Skins, MouseOverRibbonBorderBrush}}" />-->
                <Setter Property="BitmapEffect" TargetName="border">
                    <Setter.Value>
                        <OuterGlowBitmapEffect GlowSize="2" GlowColor="{DynamicResource {ComponentResourceKey odc:Skins, GlowColor}}" Opacity="1" />
                    </Setter.Value>
                </Setter>
            </Trigger>

            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource {ComponentResourceKey odc:Skins, DisabledForegroundBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type odc:RibbonComboBox}">
        <Setter Property="Template" Value="{StaticResource RibbonComboBoxTemplate}" />
        <Setter Property="Background" Value="White" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey odc:Skins, DefaultBorderBrush}}" />
        <Setter Property="MinHeight" Value="24" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>